/**************************************************
|	File:		GameplayState.h
|	Author:		Benjamin Budian
|	Course:		SGD
|	Purpose:	CGameplayState class handles the 
|				gameplay.
**************************************************/

#ifndef GAMEPLAYSTATE_H
#define GAMEPLAYSTATE_H

#include "IGameState.h"
#include "../TinyXML/tinyxml.h"

/*************************************************/
// Forward Class Declarations
class CSGD_MessageSystem;
class CSGD_EventSystem;
class IMessage;

class CEntity;
class CEntityManager;

class CBitmapFont;
class CMapImage;

/*************************************************/
// CGameplayState class
//	- handles all the gameplay
//	- singleton
class CGameplayState : public IGameState
{
public:
	///////////////////////////////////////////////
	// SINGLETON!
	static CGameplayState* GetInstance( void );
	
	///////////////////////////////////////////////
	// IGameState Interface:
	virtual void Enter( void )	override;					// load resources
	virtual void Exit( void )	override;					// unload resources

	virtual bool Input( void )	override;					// handle user input
	virtual void Update( float fElapsedTime )	override;	// update entities
	virtual void Render( void )	override;					// render entities

	void SaveGame();
	void LoadGame();

	void CreateConfigFile( void );
	bool LoadConfigFile();

	CEntityManager* GetEntityManager() { return m_pEM; }


private:
	enum PauseMenu { RESUME/*, SAVE_GAME, LOAD_GAME*/, QUIT };
	///////////////////////////////////////////////
	// Singleton (but not dynamically allocated)
	CGameplayState( void );
	virtual ~CGameplayState( void );
	CGameplayState( const CGameplayState& );
	CGameplayState& operator= ( const CGameplayState& );
	
	///////////////////////////////////////////////
	// Message callback function
	static void MessageProc( IMessage* pMsg );

	CEntity* CreateEnemy() const;
	CEntity* CreateProjectile(CEntity* pOwner, int nDirection) const;
	CEntity* CreateMagicProjectile(CEntity* pOwner, int nDirection) const;
	
	///////////////////////////////////////////////
	// Systems initialized by CGameplayState
	CSGD_MessageSystem*		m_pMS;
	CSGD_EventSystem*		m_pES;
	CEntityManager*			m_pEM;

	///////////////////////////////////////////////
	// Game Assets
	CMapImage* m_pBackgroundMap;
	CEntity* m_pPlayer;
	CEntity* m_pTestEnemy;

	bool m_bPaused;
	bool m_bDebug;
	int m_nCursor;
	int m_nNumEnemies;
	int m_nRoomTotalEnemies;

	bool m_bGameOverWin;
	bool m_bGameOverLose;

	float m_fGameOverTimer;
	
	int m_nFrames;
	int m_nFPS;
	float m_fTimer;
};

#endif //GAMEPLAYSTATE_H
